package com.liulishuo.demo.filedownloaderapplication;


import com.liulishuo.demo.filedownloaderapplication.slice.MainAbilitySlice;
import com.liulishuo.filedownloader.FileDownloadMonitor;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.bundle.IBundleManager;
import ohos.os.ProcessManager;

public class MainAbility extends Ability {
    public final String TAG = MainAbility.class.getSimpleName();
    private final int requestPermission = 1033;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        if (verifyPermission("ohos.permission.INTERNET", ProcessManager.getPid(),ProcessManager.getUid()) != IBundleManager.PERMISSION_GRANTED) {

             requestPermissionsFromUser(new String[]{"canRequestPermission"},requestPermission);
        }else{

        }
        FileDownloadMonitor.setGlobalMonitor(GlobalMonitor.getImpl());
        super.setMainRoute(MainAbilitySlice.class.getName());
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
        if(requestCode == requestPermission){
            if(grantResults[0]== IBundleManager.PERMISSION_GRANTED){

            }
        }
    }
}
